(define-module (basket line)
               #:use-module (basket)
               #:use-module (srfi srfi-1))

(export
  line?
  line-split->path
  line-split->lines)

(define (line? line)
  (and (path? line) (= (length line) 2)))

(define (line-split->path line n)
  "Splits a line into a path with N segments of equal length."
  (map (curry vec-lerp (car line) (cadr line)) (iota (+ n 1) 0 (/ n))))

(define (line-split->lines line n)
  "Splits a line into a list of N lines, each being equal length."
  (path->lines (line-split->path line n)))
